<?php

use yii\db\Migration;

class m240417_014729_diandi_hotel_order_list extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');
        
        /* 创建表 */
        $this->createTable('{{%diandi_hotel_order_list}}', [
            'id' => "int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '包间订单id'",
            'bloc_id' => "int(11) NULL COMMENT '人脸库组id'",
            'store_id' => "int(11) NULL",
            'create_time' => "datetime NULL",
            'update_time' => "datetime NULL",
            'start_time' => "datetime NULL COMMENT '开始时间'",
            'end_time' => "datetime NULL COMMENT '结束时间'",
            'member_id' => "int(11) NULL COMMENT '会员id'",
            'coupon_id' => "int(11) NULL COMMENT '使用卡券id'",
            'balance' => "decimal(10,2) NULL COMMENT '余额'",
            'amount_payable' => "decimal(10,2) NULL COMMENT '应付金额'",
            'discount' => "decimal(10,2) NULL COMMENT '优惠金额'",
            'real_pay' => "decimal(10,2) NULL DEFAULT '0.00' COMMENT '实付金额'",
            'order_number' => "varchar(100) NULL COMMENT '订单编号'",
            'pay_type' => "smallint(6) NULL COMMENT '支付方式：1.微信支付 2.余额支付 3senangpay 4现金'",
            'status' => "smallint(6) NULL COMMENT '订单状态：1.待付款 2.支付成功 3.已完成 4.已取消'",
            'hotel_id' => "int(11) NULL COMMENT '酒店ID'",
            'room_id' => "int(11) NULL COMMENT '包间id'",
            'room_num' => "int(11) NULL COMMENT '房间数'",
            'is_use' => "smallint(6) NULL COMMENT '是否正在使用 ：1.未使用  2.使用中  3.已使用 4.已过期'",
            'order_type' => "smallint(6) NULL COMMENT '订单类型 1.包间订单  2.续费订单'",
            'set_meal_id' => "int(11) NULL COMMENT '使用套餐id'",
            'set_meal_name' => "varchar(255) NULL COMMENT '使用套餐名'",
            'renew_order_id' => "int(11) NULL COMMENT '续费订单id'",
            'refund_order_number' => "varchar(100) NULL COMMENT '微信退款单号'",
            'transaction_id' => "varchar(100) NULL COMMENT '微信订单编号'",
            'pay_time' => "datetime NULL COMMENT '支付时间'",
            'renew_price' => "decimal(10,2) NULL COMMENT '半小时续费单价'",
            'renew_num' => "smallint(6) NULL COMMENT '续费单位个数'",
            'pwd' => "int(11) NULL COMMENT '开锁密码'",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='包间订单列表'");
        
        /* 索引设置 */
        
        
        /* 表数据 */
        
        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%diandi_hotel_order_list}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}

